package com.xhtranslate.common.config;

import com.aliyun.alimt20181012.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liuxuhuang
 * @version 1.0
 * @package com.xhtranslate.common.config
 * @date 2022/11/20 14:45:39
 * @description 阿里配置bean
 */
@Configuration
public class AliConfigBean {
    @Bean(value = "textTranslateBean")
    public com.aliyun.alimt20181012.Client createTextTranslateBean() throws Exception {
        Config config = new Config()
                .setAccessKeyId(TranslateConfig.AliAccessKeyId)
                .setAccessKeySecret(TranslateConfig.AliAaccessKeySecret);
        config.endpoint = "mt.cn-hangzhou.aliyuncs.com";
        return new Client(config);
    }

    @Bean(value = "ocrBean")
    public com.aliyun.ocr_api20210707.Client createOcrBean() throws Exception {
        Config config = new Config()
                .setAccessKeyId(TranslateConfig.AliAccessKeyId)
                .setAccessKeySecret(TranslateConfig.AliAaccessKeySecret);
        config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.ocr_api20210707.Client(config);
    }

}
